class Main extends egret.DisplayObjectContainer {
    private hajime:Hajime;
    private bg:egret.Bitmap;

    private page1:Page1;
    private page2:Page2;
    public constructor() {
        super();
        this.hajime = new Hajime();
        this.hajime.addEventListener(GoEvent.ResourceLoaded, this.ResourceLoaded, this);
        this.addChild(this.hajime);

        var keyboard = new KeyBoard();
        keyboard.addEventListener(KeyBoard.onkeydown, this.PressKey, this);

        GoEvent.initial();
		GoEvent.msg.addEventListener("ChangePage",this.ChangePage,this)

    }
    private ResourceLoaded(e: GoEvent) {
        this.removeChild(this.hajime);

     
      


        this.page1=new Page1();
        this.page2=new Page2();
        this.addChild(this.page1);
        // this.addChild(this.page2);
        // this.page2.Show();

    }
    private ChangePage(e:GoEvent){
        // if(e.data=="2"){
            this.addChild(this.page2);            
            this.page2.Show();
        // }
    }

      private PressKey(e) {
        if (e.data == "A") {
            console.log("A");
        }
        if (e.data == "D") {
             console.log("D");
        }
    }
}